#include<bits/stdc++.h>
#include"In.cpp"
#include"Out.cpp"
// #include"utils.cpp"
using namespace std;

const string ModeIn = "mode-in";// 只制作输入文件.in
const string ModeOut = "mode-out";// 只制作输出文件.out
const string ModeAll= "mode-all";

void closeStdInOut(bool alsoIn) {
	cout.clear();
	fclose(stdout);
	if(alsoIn) {		
		cin.clear();
		fclose(stdin);
	}
}

void G(string mode, int n) {
	if(mode!=ModeOut) {
		freopen(csn_c("./file/", n, ".in"), "w", stdout);
		ip(n);
		closeStdInOut(0);
	}
	
	if(mode!=ModeIn) {
		freopen(csn_c("./file/", n, ".in"), "r", stdin);
		freopen(csn_c("./file/", n, ".out"), "w", stdout);
		op();
		closeStdInOut(1);
	}
	
} 

int main() {
	string mode = ModeOut;// ModeAll;// 
	int beg = 0, ed = 9;

	for(int i=beg; i<=ed; i++)	G(mode, i);

	return 0;
}
